package com.lly.songhigh.utils;

/**
 * Created by dllo on 15/10/24.
 */
public class ChangeUtils {

    /**
     * 将long型数转化为万
     *
     * @param num 播放次数
     * @return
     */
    public static String getCount(long num) {
        String result;
        long count;
        long i;
        if (num > 10000) {
            count = num / 10000;
            i = num % 10000 / 1000;
            result = count + "." + i + "万";
        } else {
            count = num;
            result = count + "";
        }
        return result;
    }

    public static String formatTime(Long time) {                     //将歌曲的时间转换为分秒的制度
        String min = time / (1000 * 60) + "";
        String sec = time % (1000 * 60) + "";

        if (min.length() < 2)
            min = "0" + min;
        switch (sec.length()) {
            case 4:
                sec = "0" + sec;
                break;
            case 3:
                sec = "00" + sec;
                break;
            case 2:
                sec = "000" + sec;
                break;
            case 1:
                sec = "0000" + sec;
                break;
        }
        return min + ":" + sec.trim().substring(0, 2);
    }
}
